from rest_framework.viewsets import ModelViewSet

from goods.models import SpecificationOption, SPUSpecification
from meiduo_admin.serializers.options import OptionsSerializer, SimpleSerializer
from meiduo_admin.utils import PageNum1
from rest_framework.response import Response


class OptionsViewSet(ModelViewSet):
    queryset = SpecificationOption.objects.all()
    pagination_class = PageNum1
    serializer_class = OptionsSerializer

    def simple(self, request):
        data = SPUSpecification.objects.all()
        ser = SimpleSerializer(data, many=True)
        return Response(ser.data)
